< previous page page_149 next page >

Page 149
Type.gifListing 5.35. Coding the CheckSizeValidate method.
Public Sub CheckSizeValidate()
    '
    ' check for proper size
    '
    Dim varTemp As Variant
    '
    varTemp = Len(Text1.Text)
    '
    If varTemp < m_MinLength Or varTemp > m_MaxLength Then
        RaiseEvent CheckSizeError(varTemp)
    End If
    '
End Sub
Finally, because this is a form-level routine, modify the Text1_LostFocus event to match the code shown in Listing 5.36.
Type.gifListing 5.36. Modifying the Lost_Focus event of the TextBox.
Private Sub Text1_LostFocus()
    '
    If CheckRange = True Then InRangeValidate
    If CheckSize = True Then CheckSizeValidate
    '
End Sub
Save (and close) the control project before you switch to the TEST project to test the new options.
Testing the CheckSize Options of the VText Control
Now select the TEST.FRM form and add a label and a VText control. Set the label caption to vtxCheckSize. Set the VText control's name to vtxCheckSize. Then set the vtxCheckSize MinLength property to 5 and the MaxLength property to 10. Set the CheckSize property to True and the UpperCase property to True. Finally, set the Text property to "". Refer to Figure 5.17 for the location and size of the controls.

 
< previous page page_149 next page >

If you like this book, buy it!